package com.rx.zuul.service;

import com.rx.core.base.RxBaseConstant;
import com.rx.core.base.RxBaseService;
import com.rx.core.base.RxResponse;
import com.rx.core.common.SecretInfo;
import com.rx.zuul.bean.LoginInfo;
import com.rx.zuul.bean.LoginInfoFromUua;
import com.rx.zuul.bean.LoginInfoVo;
import com.rx.zuul.service.impl.HystrixClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @version V1.0
 * @Title: LoginService
 * @Package com.rx.zuul.service
 * @Description: 登录服务接口
 * @author: 陈锦韬
 * @date: 2021\6\28 0028
 * @Copyright: 2021 陈锦韬  All rights reserved.
 */
@FeignClient(name = "uua",fallbackFactory= HystrixClientFallbackFactory.class/*,path = "/user"*/)
public interface FeignLoginService extends RxBaseService {
    /**
     * 获取access-token
     * @param clientId
     * @param clientSecret
     * @param grantType
     * @param code
     * @param redirectUri
     * @param username
     * @param password
     * @return
     */
    @PostMapping(value = "oauth/token" ,produces = RxBaseConstant.APPLICATION_JSON_UTF8_VALUE)
    LoginInfoFromUua getToken(@RequestParam("client_id") String clientId,
                              @RequestParam("client_secret") String clientSecret,
                              @RequestParam("grant_type") String grantType,
                              @RequestParam("code") String code,
                              @RequestParam("redirect_uri") String redirectUri,
                              @RequestParam("username") String username,
                              @RequestParam("password") String password);

    /**
     * 获取密文
     * @return
     */
    @PostMapping(value = "oauth/rsa-secret" ,produces = RxBaseConstant.APPLICATION_JSON_UTF8_VALUE,
            headers = {RxBaseConstant.HEARER_LIMIT_MARK + "=" + RxBaseConstant.SECRET_LIMIT_MARK})
    SecretInfo secret();
}
